package Cotrol
{
	import GameItem.IGameItem;
	
	import Model.BattleMapData;
	
	import flash.geom.Rectangle;

	public class MapControl
	{
		private static var m_instance:MapControl;
		
		private var m_battleMap:BattleMapData;
		public static function getInstance():MapControl
		{
			if(null==m_instance)
			{
				m_instance=new MapControl();
			}
			return m_instance;
		}
		public function MapControl()
		{
			m_battleMap=new BattleMapData();
			m_battleMap.initMapData();
		}
		public function addGameItemToMap(item:IGameItem):void
		{
			m_battleMap.addItem(createGameitemRect(item));
		}
		public function removeItemFromMap(item:IGameItem):void
		{
			m_battleMap.removeItem(createGameitemRect(item));
		}
		public function hitTest(item:IGameItem):Boolean
		{
			return m_battleMap.hitTest(createGameitemRect(item));
		}
		private function createGameitemRect(item:IGameItem):Rectangle
		{
			var rect:Rectangle=new Rectangle(item.position.x,item.position.y,item.sizeX,item.sizeY);
			return rect;
		}
	}
}